package com.dgut.smart_house.util;

import com.alibaba.fastjson.JSON;
import com.dgut.smart_house.enums.ResultCode;
import org.springframework.stereotype.Component;

@Component
public class RestResult {

    private int code;//状态码

    private String message;//消息

    private Object data;//数据



    public void setCode(int code) {
        this.code = code;
    }


    public int getCode() {
        return code;
    }

    public RestResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public RestResult setData(Object data) {
        this.data = data;
        return this;
    }

    public Object getData() {
        return data;
    }

    public RestResult(){

    }

    public RestResult(ResultCode resultCode, Object data) {
        this.code = resultCode.getCode();
        this.message=resultCode.getMsg();
        this.data = data;
    }

    public RestResult(Integer code,String msg, Object data) {
        this.code = code;
        this.message=msg;
        this.data = data;
    }


    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

}